package com.byzk.invoice.xml.Doc_0.Tpls.Tpl_0;

import com.byzk.invoice.util.DocumentUtil;
import org.dom4j.*;

import java.io.File;

/**
 * 创建Content.xml.
 *
 * @author 康鹏 2020-05-20
 */
public class Content {

    /**
     * 创建Doc_0/Tpls/Tpl_0/Content.xml.
     * @param contentXmlPath Content.xml存放路径
     * @throws Exception Exception
     */
    public static void createContentXml(String contentXmlPath) throws Exception {

        Namespace namespace = new Namespace("ofd", "http://www.ofdspec.org/2016");
        //创建外层<ofd:Page />
        Element rootElt = DocumentHelper.createElement(new QName("Page", namespace));
        //创建<ofd:Content />
        Element contentElt = rootElt.addElement("ofd:Content");
        //创建<ofd:Layer />
        Element layerElt = contentElt.addElement("ofd:Layer");
        layerElt.addAttribute("ID", "3");
        //创建<ofd:PathObject />
        Element pathObjectElt4 = layerElt.addElement("ofd:PathObject");
        pathObjectElt4.addAttribute("ID", "4");
        pathObjectElt4.addAttribute("Boundary", "68.5 18 73 0.25");
        pathObjectElt4.addAttribute("LineWidth", "0.25");
        Element strokeColorElt4 = pathObjectElt4.addElement("ofd:StrokeColor");
        strokeColorElt4.addAttribute("Value", "156 82 35");
        Element abbreviatedDataElt4 = pathObjectElt4.addElement("ofd:AbbreviatedData");
        abbreviatedDataElt4.setText("M 0 0 L 73 0");

        Element pathObjectElt5 = layerElt.addElement("ofd:PathObject");
        pathObjectElt5.addAttribute("ID", "5");
        pathObjectElt5.addAttribute("Boundary", "68.5 19 73 0.25");
        pathObjectElt5.addAttribute("LineWidth", "0.25");
        Element strokeColorElt5 = pathObjectElt5.addElement("ofd:StrokeColor");
        strokeColorElt5.addAttribute("Value", "156 82 35");
        Element abbreviatedDataElt5 = pathObjectElt5.addElement("ofd:AbbreviatedData");
        abbreviatedDataElt5.setText("M 0 0 L 73 0");

        Document document = DocumentHelper.createDocument(rootElt);
        DocumentUtil.writer(document, contentXmlPath + File.separator + "Doc_0" + File.separator + "Tpls"
                + File.separator + "Tpl_0" + File.separator + "Content.xml", true);
    }

}
